package com.water.camera.activity;

import android.view.View;

import com.plata.base.base.AbsBaseActivity;
import com.plata.base.utils.WeakHandler;
import com.water.camera.fragment.BaseDialogFragment;
import com.water.camera.fragment.LoadingDlg;
import com.water.camera.util.Utils;

import me.jessyan.autosize.internal.CancelAdapt;

public abstract class BaseActivity extends AbsBaseActivity implements CancelAdapt {

    protected WeakHandler h = new WeakHandler();

    @Override
    public void setContentView(View view) {
        super.setContentView(view);
//        StatusBarUtil.setTranslucent(this, 60);
        if (paddingTop()) {
            view.setPadding(0, Utils.getStatusBarHeight(this), 0, 0);
        }
    }

    protected boolean paddingTop() {
        return true;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        h.removeCallbacksAndMessages(null);
    }

    LoadingDlg loadingDlg = null;

    protected void showLoading() {
        if (loadingDlg == null) {
            loadingDlg = new LoadingDlg();
            loadingDlg.setOnDismissListener(new BaseDialogFragment.OnDismissListener() {
                @Override
                public void onDismiss(boolean isOk, Object value) {
                    loadingDlg = null;
                }
            });
        }
        loadingDlg.show(getSupportFragmentManager(), "");
    }

    protected void hideLoading() {
        if (loadingDlg != null) {
            loadingDlg.dismiss();
        }
    }
}
